package name.zeno.qrcode;

import android.app.Activity;
import android.content.Intent;
import android.graphics.PointF;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;

import com.dlazaro66.qrcodereaderview.QRCodeReaderView;

public class QRCodeReaderActivity extends Activity implements QRCodeReaderView.OnQRCodeReadListener
{

    QRCodeReaderView qrView;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_read_qrcode);
        qrView = (QRCodeReaderView) findViewById(R.id.qrdecoderview);
        qrView.setOnQRCodeReadListener(this);
    }

    @Override
    public void onQRCodeRead(String text, PointF[] points)
    {
        Intent data = new Intent();
        data.putExtra("result",text);
        setResult(RESULT_OK,data);
        finish();
    }

    @Override
    public void cameraNotFound()
    {

    }

    @Override
    public void QRCodeNotFoundOnCamImage()
    {

    }

    @Override
    protected void onResume() {
        super.onResume();
        qrView.getCameraManager().startPreview();
    }

    @Override
    protected void onPause() {
        super.onPause();
        qrView.getCameraManager().stopPreview();
    }
}
